home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 1999 November / SGI IRIX 6.5 Applications 1999 November.iso / CDrelnotes < prev   
Text File  |  1995-08-20  |  3KB  |  132 lines

  1. #! /bin/sh
  2. #Tag 0x00000600
  3.  
  4. # 'relnotes' - View on-line release notes
  5.  
  6. SRCDIR=`dirname $0`/relnotes/
  7.  
  8. Usage="\n
  9.     'relnotes -h' -- print this message\n
  10.     'relnotes' -- list products that have on-line release notes \n
  11. \t\t\tcurrently installed\n
  12.     'relnotes <product>' -- show table of contents for a product's \n
  13. \t\t\ton-line release notes\n
  14.     'relnotes <product> <chapter> ... ' -- display specific chapters of \n
  15. \t\t\t\ta product's on-line release notes\n
  16.     'relnotes -t <product> <chapter> ... ' -- print specific chapters of \n
  17. \t\t\t\ta product's on-line release notes\n"
  18.  
  19. if [ "$1" = "-h" ] # give help and exit
  20. then
  21.     echo $Usage
  22.     exit
  23. fi
  24.  
  25. list_relnotes=/tmp/relnoteslist$$
  26. product=/tmp/relnotesproduct$$
  27. cleanup="rm -f $list_relnotes $product"
  28. trap "$cleanup" 1 2 3 15
  29.  
  30. # Create a list of products which have release notes installed.
  31. HERE=`pwd`
  32. cd $SRCDIR
  33. find . -follow -type f -name "ch*.z" -print |  \
  34.     sed -e 's%./%%' -e 's%/ch.*\.z%%' | sort -u > $list_relnotes
  35. cd $HERE
  36. if [ ! -s $list_relnotes ]
  37. then
  38.     echo "Sorry, but no products have release notes installed\n"
  39.     rm -f $list_relnotes
  40.     exit
  41. fi
  42.  
  43. if [ $# -eq 0 ]    # no args - show installed relnotes
  44. then
  45.     echo "The following products have release notes installed:\n"
  46.     cat $list_relnotes
  47.     $cleanup
  48.     exit
  49. fi
  50.  
  51. validproduct=no
  52. tflag=
  53. while [ $# -gt 0 ] # As long as we have arguments ....
  54. do
  55.     # Recognize old-style args, but don't support them.
  56.     if [ "$1" = "-p" ]
  57.     then
  58.       echo "The -p and -c options are no longer needed."
  59.       echo $Usage
  60.       $cleanup 
  61.       exit 1
  62.     fi
  63.  
  64.     # Support for printing chapters.
  65.     if [ "$1" = "-t" ]
  66.     then
  67.       tflag=$1
  68.       shift 
  69.       continue
  70.     fi
  71.     
  72.     # Invalid option?
  73.     if [ `expr "$1" : '\(.\).*'` = "-" ]
  74.     then
  75.       echo "$1 is an invalid option."
  76.       echo $Usage
  77.       $cleanup
  78.       exit 1
  79.     fi
  80.  
  81.     if [ "$validproduct" = "no" ]
  82.     then
  83.       echo $1 > $product
  84.       match=`comm -12 $list_relnotes $product  | wc -l`
  85.       if [ $match -eq 1 ];
  86.       then
  87.          validproduct=$1    
  88.          shift
  89.          if [ $# -gt 0 ];
  90.          then
  91.             continue
  92.          fi
  93.          if [ -f $SRCDIR$validproduct/TC ];
  94.          then
  95.             echo "The chapters for the \"$validproduct\" product's release notes are:\n"
  96.             cat $SRCDIR$validproduct/TC 
  97.          else
  98.             echo "The \"$validproduct\" product's release notes are installed, "
  99.             echo "but its table of contents file is missing.\n"
  100.             echo "The chapters that are installed are:\n"
  101.             cd $SRCDIR${validproduct}; /bin/ls ch*.z | sed -e 's/ch//' -e 's/.z//'
  102.          fi
  103.       else  # Not an installed product
  104.          echo "Sorry, but there are no installed release notes for the \"$1\" product.\n"
  105.          $cleanup ; exit 1
  106.       fi
  107.     else # Have a valid product.
  108.       cd $SRCDIR$validproduct
  109.           # Check for the existence of ch#.z. If not found check
  110.           # for ch0#.z. If still not found report an error
  111.           if [ -r ch${1}.z ]; then
  112.                 man $tflag -d ch${1}.z
  113.           elif [ -r ch0${1}.z ]; then
  114.                 man $tflag -d ch0${1}.z
  115.           else
  116.                 echo "There is no chapter $1 in the \"$validproduct\" release notes."
  117.           fi
  118.       shift
  119.       if [ $# -gt 0 ];
  120.       then
  121.         echo "Next chapter ('q' to quit):\c"
  122.         read ans
  123.         if [ "$ans" = "q" ];
  124.         then
  125.             $cleanup
  126.             exit
  127.         fi
  128.       fi
  129.     fi
  130. done
  131. $cleanup
  132.